/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package transformGrammar;

/**
 *
 * @author daniel
 */
public class SplitGrammarRule {
    public final static String openparant = "(";
    public final static String closedparant = ")";
    public final static String apostrof = "'";
    
    static public String [] splitRule (String rule ){
    	
    	if (rule.trim().endsWith(";"))
    		rule = rule.trim().substring(0, rule.trim().length()-1);
        String [] split = rule.split("\\|");
        return split;
    } 
    
    public static String stripRuleName(String grammar){
        
    	if (grammar.contains(":")){
            if (grammar.startsWith(":"))
                return grammar.substring(1);
            else 
                if ( grammar.endsWith(":"))
                    return "";
                else
                    return grammar.substring(grammar.indexOf(":")+1);
        }
        else
            return grammar;
    }
    
    public static int countApp (String str,char c ){
    	int count = 0 ;
    	for (int i = 0 ; i < str.length() ; i++) {
    		if (str.charAt(i)==c)
    			count++;
    	}
    	return count;
    }
    public static  void  main(String a[]){
    }
}
